package com.verbetia.musictrends.web.auth;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.verbetia.musictrends.persistence.hsqldb.UserEntity;
import com.verbetia.musictrends.persistence.hsqldb.UsersPersMngr;

public class RegisterUser extends HttpServlet {
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{		
		
		String username = request.getParameter("user");
		String password = request.getParameter("pass");
		String repassword = request.getParameter("repass");
		
		if (!password.equals(repassword))
				return;
		
		
		UsersPersMngr users = new UsersPersMngr();
				
		try {
			users.createInstance(username, password, 0); 
		} catch (Exception e)
		{
			System.out.println(e);			
		}
		
		
		
		response.sendRedirect("login.jsp");
		
			
	}
		

}
